﻿using System;

using System.Collections.Generic;
using System.Text;

namespace Silvermoon.Animations
{
    public class ElasticEase : EasingFunctionBase
    {
        public static readonly ElasticEase Out = new ElasticEase { Mode = EasingMode.EaseOut };

        private int oscillations = 3;

        public int Oscillations
        {
            get { return oscillations; }
            set
            {
                if (value < 1) throw new ArgumentOutOfRangeException("Oscillations");
                oscillations = value;
            }

        }

        public double Springiness = 4d;

        protected override float EaseValue(float normalizedTime)
        {
            double t = normalizedTime;
            return (float)(Math.Cos(t * Math.PI * 2d * oscillations) * Math.Pow(t, Springiness));
        }
    }

    public class BounceEase : ElasticEase
    {
        protected override float EaseValue(float normalizedTime)
        {
            float v= base.EaseValue(normalizedTime);
            return v < 0f ? -v : v;
        }
    }
}
